#include "problems.h"

constexpr int upperbound = 999; 
long long sumdivby(int n);

int Problem1()
{
	long long sum = 0;

	//Time Complexity is O(2n)
	for (int i = 0; i <= upperbound; i++)
	{
		if (i % 3 == 0 || i % 5 == 0)
			sum += i;
	}

	//Time Complexity is O(3)
	sum = sumdivby(3) + sumdivby(5) - sumdivby(15);

	return sum;
}

long long sumdivby(int n)
{
	return n * (upperbound / n * (upperbound / n + 1)) / 2;
}